package com.quan.system.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quan.common.core.MyBaseServiceImpl;
import com.quan.system.entity.SystemCompany;
import com.quan.system.mapper.SystemCompanyMapper;
import com.quan.system.service.SystemCompanyService;

/**
 * <p>
 * 公司表 服务实现类
 * </p>
 *
 * @author 杨浩泉
 * @since 2019-06-21
 */
@Service
public class SystemCompanyServiceImpl extends MyBaseServiceImpl<SystemCompanyMapper, SystemCompany> implements SystemCompanyService {

	@Override
	public boolean removeById(Serializable id) {
		return this.recursiveDelete(id);
	}
	
	private boolean recursiveDelete(Serializable id) {
		QueryWrapper<SystemCompany> queryWrapper = new QueryWrapper<SystemCompany>();
		queryWrapper.eq("pid", id);
		
		List<SystemCompany> child = super.list(queryWrapper) ;
		if(null != child) {
			for (SystemCompany entity : child) {
				recursiveDelete(entity.getId());
			}
		}
		return super.removeById(id);
	}
	
}
